import { defineStore } from 'pinia';
// import piniaPluginPersist from 'pinia-plugin-persist';

export const useStore = defineStore('storeId', {
  // 推荐使用 完整类型推断的箭头函数
  state: () => {
    return {
      // 所有这些属性都将自动推断其类型
      counter: 777,
      name: 'Eduardo',
      isAdmin: true,
    };
  },
  getters: {
    changeNum(): number {
      console.log('getters');
      return this.counter + 100;
    },
  },
  actions: {
    upNum(val: number) {
      console.log(val);
      this.counter += val;
    },
  },
  // persist: {
  //   enabled: true,
  //   strategies: [
  //     {
  //       key: 'key',
  //       storage: localStorage,
  //       path: ['name'],
  //     },
  //   ],
  // },
});

// 持久化
// const store = createPinia();
// store.use(piniaPluginPersist);
// export default store;
